﻿
@{
    Layout = "";
}
<style>
    .clearfix:after {
        content: ".";
        display: block;
        height: 0;
        clear: both;
        visibility: hidden;
    }

    .clearfix {
        *+height: 1%;
    }

    .plr10 {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .list_ry {
        background-color: #fff;
    }

    .look_details {
        color: #9e9e9e;
        font-size: 12px;
    }

    .fctperson_row {
        padding: 10px 0 10px;
        position: relative;
    }

    .fctperson_row_header {
        width: 35px;
        height: 35px;
        overflow: hidden;
        border-radius: 50%;
        border: 1px solid #eb272a;
        float: left;
        margin-right: 5px;
    }

        .fctperson_row_header img {
            width: 100%;
        }

    .fctperson_row_header_tz {
        position: absolute;
        left: 30px;
        top: 3px;
        width: 20px;
    }

    .fctperson_row_n {
        float: left;
        height: 35px;
        line-height: 35px;
    }

    .fctperson_row_r {
        float: right;
        height: 35px;
        line-height: 35px;
        font-size: 12px;
    }

        .fctperson_row_r .price {
            color: #ff3030;
            font-size: 12px;
            margin-left: 10px;
        }

    .fctperson_row_more {
        height: 30px;
        line-height: 30px;
        text-align: center;
    }
</style>

<div ng-controller="ActivityTeamController">
    <div>
        <div class="flayout_h_eachBox">
            <div class="flayout_h_hdBox">
                <div class="flayout_h_hdheader"><img src="{{model.UserHeadImg}}"></div>
                <div class="flayout_h_hdright">
                    <p class="flayout_h_userName">{{model.UserName}}</p>
                    <p class="flayout_h_personNum">发起{{model.ParticipateNum}}人团</p>
                    <a href="javascript:void(0)" class="w_paysys_look1 pull_right toShare f_absolute">分享好友</a>
                </div>
            </div>
            <div class="flayout_h_groupPro" ng-click="goactivity(model.ActivityId)">
                <div class="flayout_h_proimg">
                    <img src="{{ImgHostUrl+model.CoverImg}}">
                </div>
                <div class="flayout_h_proInfo">
                    <p class="flayout_h_proName">{{model.ActivityName}}</p>
                    <div class="flayout_h_proPrice">

                        <label class="txt3">价格</label><span class="txt1">¥{{model.ActivityPrice}}</span>

                    </div>
                </div>
            </div>
            <!-- 已有的拼团人数 -->
            <div class="flayout_h_groupPersonNum">
                <div class="flayout_h_groupPersonNumHd">
                    <span class="h_line_span"></span><label class="h_hd_txt1">已有{{model.NowParticipateNum}}人参加</label><span class="h_line_span"></span>
                </div>
                <div ng-repeat="member in members">
                    <img ng-show="$index<1" src="{{member.UserHeadImg}}" class="hd_group_header">
                </div>

                <div class="h_bd">
                    <span class="h_bd_txt1">剩余团有效时间：</span>
                    <label class="h_bd_txt2 ftz_time_part" EndTime="{{model.EndTime}}"></label>
                </div>
            </div>
            <!--end 已有的拼团人数 -->
            <!-- 按钮 -->
            <p class="h_btn" ng-show="isend==1" ng-click="goopen(model.ActivityId,model.Id)">{{IsJoin?"已参团":"我要参团"}}</p>
            <!-- 按钮 -->
        </div>
        <div class="list_ry" ng-repeat="member in members">
            <!--end 参与人员的列表 -->
            <div class="fctperson_row clearfix border_top plr10">
                <img ng-show="$index<1" class="fctperson_row_header_tz" src="/Content/images/head_tz.png">
                <div class="fctperson_row_header"><img src="{{member.UserHeadImg}}"></div>
                <div class="fctperson_row_n">{{member.UserName}}</div>
                <div class="fctperson_row_r">{{member.JoinTime}}<span class="price">¥{{member.PaymentAmount}}</span></div>
            </div>
            <!--end 参与人员的列表 -->
        </div>

    </div>
</div>
<!-- 弹出层 -->
<div class="fpop_bg"></div>
<!-- 弹出提示 -->
<img src="/Content/images/24.png" alt="点击右上角分享" class="toShareImg" style="position: absolute;top:0;right: 0;width: 90%;display: none;z-index:2">
<!--end 弹出提示 -->
<!--end 弹出层 -->
<script>
    $(".fpop_bg").click(function () {
        $(".fpop_bg").hide();
        $(".toShareImg").hide();
    })
    $(".w_paysys_look1").click(function () {
        $(".fpop_bg").show();
        $(".toShareImg").show();
    })

    App.controller('ActivityTeamController', [
           '$scope', '$http', '$rootScope', 'Reddit', '$stateParams', '$state',
       function ($scope, $http, $rootScope, Reddit, $stateParams, $state) {
           $scope.model = {};
           $scope.members = {};
           $scope.nowtime = new Date();
           $scope.isend = 0;
           $http.post("/Activity/GetActivityTeamInfo", { id: $stateParams.Id }).then(function (response) {
               if (response.data.Result && response.data.Result != "") {
                   $scope.model = response.data.Result;
                   $scope.IsJoin = response.data.IsJoin;
                   $scope.members = response.data.Result.ActivityTeamMembers;
                   var participatenum = 0;
                   var uid = response.data.UserId;
                   for (var i = 0; i < $scope.members.length; i++) {
                       if ($scope.members[i].UserId == uid) {
                           participatenum++;
                       }
                   }
                   
                   if ($scope.nowtime < new Date($scope.model.EndTime.replace(/-/g, '/')) && $scope.model.IsParticipateNum > participatenum) {
                       $scope.isend = 1;
                   }
               }
           });

           $scope.goopen = function (aid, id) {
               if ($scope.IsJoin)
               {
                   return;
               }
               $state.go('shop.actorder', { "activityId": aid, "groupId": id });
           }

           $scope.goactivity = function (id) {
               debugger;
               $state.go('activity.activityinfo', { "Id": id });
           }
           var tt = function () {
               $rootScope.WxShare($rootScope.pageTitle(), '优品三悦', location.href, $rootScope.LogoUrl);
           }

           setTimeout(tt, 1000)
       }]);


    function GetRTime() {
        $(".ftz_time_part").each(function () {
            var e = $(this).attr("EndTime").replace(/-/g, '/');

            var EndTime = new Date(e);

            var NowTime = new Date();
            var t = EndTime.getTime() - NowTime.getTime();
            var d = 0;
            var h = 0;
            var m = 0;
            var s = 0;
            if (t >= 0) {
                d = Math.floor(t / 1000 / 60 / 60 / 24);
                h = Math.floor(t / 1000 / 60 / 60 % 24);
                m = Math.floor(t / 1000 / 60 % 60);
                s = Math.floor(t / 1000 % 60);
            }
            var timetxt = "";
            if (d > 0) {
                timetxt += d + "天";
            }
            if (h > 0) {
                if (h < 10) {
                    h = "0" + h;
                }
                timetxt += " " + h + "小时";
            }
            if (m > 0) {
                if (m < 10) {
                    m = "0" + m;
                }
                timetxt += "：" + m + "分";
            }
            if (s > 0) {
                if (s < 10) {
                    s = "0" + s;
                }
                timetxt += "：" + s + "秒";
            }
            if (timetxt == "") {
                timetxt = "活动已结束！";
            }
            $(this).html(timetxt);
        })
    }

    setInterval('GetRTime()', 1000);
</script>

